const readline = require('readline');

async function askBackend(question: string) {
  const response = await fetch('http://172.20.10.4:8000/query', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      team: 'edu_assistant_team',
      query: question
    })
  });
  const data = await response.json();
  console.log('\u540e\u7aef\u8fd4\u56de\u5185\u5bb9:', data);
  if (data.responser) {
    console.log('AI\u56de\u7b54:', data.responser);
  }
}

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question('\u8bf7\u8f93\u5165\u4f60\u7684\u95ee\u9898\uff1a', (input) => {
  askBackend(input).then(() => rl.close());
}); 